module Analyzer.D.lexical.numbers;
import Analyzer.D.util.textScanner;
import Analyzer.D.lexical.token_enum;

public TOK scanNumber( TextScanner sc )
{
    while( true )
    {
        sc.read();
        if( !isNumberPart( sc.peek() ) )
        {
            break;
        }
        if( sc.peek(2) == ".." )
        {
            break;
        }
    }
    
    return TOK.Tnumber;
}

bool isNumberStart( char c )
{
    return isDigit( c );
}

bool isDotFloatStart( char[] cc )
{
    return cc[0] == '.' && isDigit( cc[1] );
}
    
bool isNumberPart( char c )
{
    return isDigit(c) || isLetter(c) || c == '.' || c == '_';
}

bool isInRange( char c, char a, char b )
{
    return (c >= a && c <= b);
}

bool isDigit( char c )
{
    return isInRange(c, '0','9');
}

bool isLetter( char c )
{
    return isInRange(c, 'a','z') || isInRange(c, 'A','Z');
}

